package Maze;

import java.util.Scanner;

public class code59 {
    //方向控制数组  //右下左上
    static int[] tx = {0, 1, 0, -1};
    static int[] ty = {1, 0, -1, 0};

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        node[][] map = new node[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                map[i][j] = new node(i, j, 0);
            }
        }
        int[][] isFlag = new int[n][n];
        node start = new node(0, 0, 1);
        map[start.getX()][start.getY()] = start;
        isFlag[start.getX()][start.getY()] = 1;
        dfs(start, map, isFlag);
        print(map);
    }

    private static void dfs(node start, node[][] map, int[][] isFlag) {
        for (int i = 0; i <= 3; i++) {
            if (start.getX() == map.length - 1 && start.getY() == 0) {
                tx[0] = -1;
                tx[1] = 0;
                tx[2] = 1;
                tx[3] = 0;
                ty[0] = 0;
                ty[1] = 1;
                ty[2] = 0;
                ty[3] = -1;
            }
            int x = start.getX() + tx[i];
            int y = start.getY() + ty[i];
            if (x >= 0 && x < map.length && y >= 0 && y < map[0].length && isFlag[x][y] != 1) {
                node next = new node(x, y, start.getValue() + 1);
                map[x][y] = next;
                isFlag[x][y] = 1;
                dfs(next, map, isFlag);
            }
        }
    }

    private static void print(node[][] map) {
        System.out.println("====");
        for (node[] line : map) {
            for (node node : line) {
                System.out.print(node.getValue() + " ");
            }
            System.out.println();
        }
        System.out.println("====");
    }

    static class node {
        int x;
        int y;
        int value;

        public int getX() {
            return x;
        }

        public void setX(int x) {
            this.x = x;
        }

        public int getY() {
            return y;
        }

        public void setY(int y) {
            this.y = y;
        }

        public int getValue() {
            return value;
        }

        public void setValue(int value) {
            this.value = value;
        }

        public node(int x, int y, int value) {
            this.x = x;
            this.y = y;
            this.value = value;
        }
    }
}
